package com.zbkj.dal.base.enums;

import com.zbkj.dal.common.exception.CrmebException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalTime;

@AllArgsConstructor
public enum PickupAppointmentAvailableTime {

    // f1
    T1("TTZQC", LocalTime.of(9, 0, 0), LocalTime.of(11, 0, 0)),
    // f1
    T2("VFJRQ", LocalTime.of(11, 0, 0), LocalTime.of(13, 0, 0)),
    // f2
    T3("DOYKN", LocalTime.of(13, 0, 0), LocalTime.of(15, 0, 0)),
    // f3
    T4("OXVMD", LocalTime.of(15, 0, 0), LocalTime.of(17, 0, 0)),
    // f4
    T5("KKUQV", LocalTime.of(17, 0, 0), LocalTime.of(19, 0, 0)),

    ;

    @Getter
    private final String code;

    @Getter
    private final LocalTime start;

    @Getter
    private final LocalTime end;

    public static PickupAppointmentAvailableTime getByCode(String code) {
        for (PickupAppointmentAvailableTime value : PickupAppointmentAvailableTime.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new CrmebException("预约时间不支持");
    }
}
